/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package Beans;

import Conexion.cConexion;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.Statement;
import java.util.ArrayList;
import java.util.List;

/**
 *
 * @author Emanuel
 */
public class beanLaboratorista {
    public static String insertar = "insert into laboratorista (carnet_p)values(?)";
    public static String modificar = "update laboratorista set carnet_p=? where codigo_l=?";
    public static String eliminar = "delete from laboratorista where codigo_l=?";
    
    public static String seleccionar = "select l.codigo_l, p.carnet_p, p.nombre_pe, p.apellido_pe from laboratorista as l, personal as p where l.carnet_p=p.carnet_p";
    
    private int codigo_l;
    private int carnet_p;
    private String nombre_pe;
    private String apellido_pe;

    public String getApellido_pe() {
        return apellido_pe;
    }

    public void setApellido_pe(String apellido_pe) {
        this.apellido_pe = apellido_pe;
    }

    public int getCarnet_p() {
        return carnet_p;
    }

    public void setCarnet_p(int carnet_p) {
        this.carnet_p = carnet_p;
    }

    public int getCodigo_l() {
        return codigo_l;
    }

    public void setCodigo_l(int codigo_i) {
        this.codigo_l = codigo_l;
    }

    public String getNombre_pe() {
        return nombre_pe;
    }

    public void setNombre_pe(String nombre_pe) {
        this.nombre_pe = nombre_pe;
    }

    
    
    public List<beanLaboratorista> getListado() {
        List< beanLaboratorista> lista = new ArrayList< beanLaboratorista>(0);
        try {
            Connection cnn =  cConexion.conectar_ds();
            ResultSet rset = null;
            Statement sta = cnn.createStatement();
            rset = sta.executeQuery(beanLaboratorista.seleccionar);

            while (rset.next()) {
            beanLaboratorista current = new  beanLaboratorista ();
            current.setCodigo_l(rset.getInt("codigo_l"));
            current.setCarnet_p(rset.getInt("carnet_p"));
            current.setNombre_pe(rset.getString("nombre_pe"));
            current.setApellido_pe(rset.getString("apellido_pe"));
            
         
            lista.add(current);
            }
            rset.close();
            sta.close();
            cnn.close();

        } catch (Exception ex) {
        } finally {
            return lista;
        }
    }
}
